package main

import (
	"fmt"
	"github.com/PuerkitoBio/goquery"
	"log"
	"net/http"
)

//
//func getMainDomain(address string) string {
//	if !strings.HasPrefix(address, "http://") && !strings.HasPrefix(address, "https://") {
//		address = "http://" + address
//	}
//
//	u, err := url.Parse(address)
//	if err != nil {
//		return address
//	}
//
//	hostname := u.Hostname()
//	if strings.HasPrefix(hostname, "www.") {
//		hostname = strings.TrimPrefix(hostname, "www.")
//	}
//
//	return hostname
//}

func main() {
	url := "https://www.whois.com/whois/ip138.com"
	res, err := http.Get(url)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()
	if res.StatusCode != 200 {
		log.Fatalf("status code error: %d %s", res.StatusCode, res.Status)
	}

	// Load the HTML document
	doc, err := goquery.NewDocumentFromReader(res.Body)
	if err != nil {
		log.Fatal(err)
	}

	whoisEN := doc.Find("#registrarData").Text()
	fmt.Println(whoisEN)
}
